﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using SES.CMS.DO;
using SES.CMS.BL;

namespace SES.CMS.AdminCP.PageUC
{
    public partial class ucListLibFile : System.Web.UI.UserControl
    {
        DataTable dtFile = new DataTable();
        protected void Page_Load(object sender, EventArgs e)
        {
            dtFile = new cmsLibsFileBL().SelectAll();
            gvFile.DataSource = dtFile;
            gvFile.DataBind();
        }

        protected void gvFile_StartRowEditing(object sender, DevExpress.Web.Data.ASPxStartRowEditingEventArgs e)
        {
            int FileID = int.Parse(e.EditingKeyValue.ToString());
            Response.Redirect("Default.aspx?Page=LibsFile&FileID=" + FileID.ToString());
        }

        protected void cboCategory_SelectedIndexChanged(object sender, EventArgs e)
        {
            gvFile.DataSource = new cmsArticleBL().SelectAll();
            gvFile.DataBind();
        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {
            Response.Redirect("Default.aspx?Page=LibsFile");
        }

        protected void gvFile_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
        {
            int itemFileIndex = gvFile.FindVisibleIndexByKeyValue(e.Keys[gvFile.KeyFieldName]);
            new cmsLibsFileBL().Delete(new cmsLibsFileDO { FileID = Convert.ToInt32(dtFile.Rows[itemFileIndex]["FileID"].ToString()) });
            Functions.Alert("Xóa bản tin thành công!", Request.Url.ToString());
            Response.Redirect("Default.aspx?Page=ListLibFile");
        }
    }
}